app.model = {};

(function() {
	
	app.model.sampleRSS = function(_args){
		
		Ti.App.Properties.setString()
		
		var xhr = Titanium.Network.createHTTPClient();
		xhr.onload = function(e){
			try{
				// Ti.API.info('responseText: ' + this.responseText);
				// Ti.API.info('responseXML: ' + xhr.responseXML);
				
				// manipulate response data here
				var doc = xhr.responseXML.documentElement; Ti.API.info('doc: ' + JSON.stringify(doc));
				// var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue; Ti.API.info('title: ' + doctitle);
				// var doclink = doc.evaluate("//channel/link/text()").item(0).nodeValue; Ti.API.info('link: ' + doclink);
				// var docdesc = doc.evaluate("//channel/description/text()").item(0).nodeValue; Ti.API.info('desc: ' + docdesc);
// 				
				// var items = doc.evaluate("//channel/item"); Ti.API.info('items: ' + items);
				// for(var i = 0; i < items.getLength(); i++) {
					// var item = items.item(i); //Ti.API.info('item node: ' + item);
					// if(item.getNodeType() == item.ELEMENT_NODE) { Ti.API.info('   element: ' + item);
						// var title = item.getElementsByTagName('title').item(0).text; Ti.API.info('title: ' + title);
						// var link = item.getElementsByTagName('link').item(0).text; Ti.API.info('link: ' + link);
					// }
				// }
				
				var channel = doc.getElementsByTagName('channel').item(0);
				var title = channel.getElementsByTagName('title').item(0).text; Ti.API.info('title: ' + title);
				var link = channel.getElementsByTagName('link').item(0).text; Ti.API.info('link: ' + link);
				var description = channel.getElementsByTagName('description').item(0).text; Ti.API.info('description: ' + description);
				var itemList = channel.getElementsByTagName('item');
				for(var i=0; i<itemList.length; i++){
					Ti.API.info(itemList.item(i));
					var itemtitle = itemList.item(i).getElementsByTagName('title').item(0).text; Ti.API.info('itemtitle: ' + itemtitle);
					var itemdescription = itemList.item(i).getElementsByTagName('description').item(0).text; Ti.API.info('itemdescription: ' + itemdescription);
					var itemlink = itemList.item(i).getElementsByTagName('link').item(0).text; Ti.API.info('itemlink: ' + itemlink);
					var itempubDate = itemList.item(i).getElementsByTagName('pubDate').item(0).text; Ti.API.info('itempubDate: ' + itempubDate);
				}
			}catch(E) {
				Ti.API.info('XML Parse Error: ' + E);
			}
		
		};
		xhr.open('GET', 'http://www.inquirer.net/fullfeed');
		xhr.send();
	}
	
})();

Ti.include(
	'/app/model/Inquirer.js',
	'/app/model/ManilaBulletin.js',
	'/app/model/ABSCBN.js'
)
